package com.deram.ctin.serv.search.solr.reporsitory.impl;

import com.deram.ctin.serv.search.entity.solr.bean.SolrCustomsInfo;
import com.deram.ctin.serv.search.solr.reporsitory.TODOCustomsInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.core.query.Criteria;
import org.springframework.data.solr.core.query.FacetQuery;
import org.springframework.data.solr.core.query.SimpleQuery;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public class TODOCustomsInfoDaoImpl /*implements TODOCustomsInfoDao*/ {

//    @Autowired
//    private SolrTemplate solrTemplate;
//
//
//    @Override
//    public List<SolrCustomsInfo> search(String searchTerm) {
//        String[] words = searchTerm.split(" ");
//        Criteria criteria = createSearchConditions(words);
//        SimpleQuery search = new SimpleQuery(criteria);
//        Page reslut = solrTemplate.queryForFacetPage((FacetQuery) search,SolrCustomsInfo.class);
//        return reslut.getContent();
//    }
//
//    private Criteria createSearchConditions(String[] words) {
//        Criteria conditions = null;
//        for (String word: words) {
//            if (conditions == null) {
//                conditions = new Criteria("hsCode").contains("12312")
//                        .or(new Criteria("hsName").contains("蕾薄"));
//            }
//            else {
//                conditions = conditions.or(new Criteria("hsName").contains("12312"))
//                        .or(new Criteria("hsName").contains("蕾薄"));
//            }
//        }
//        return conditions;
//    }
}